package Ontology;

import java.util.Vector;

import javax.swing.JOptionPane;

public class Messages 
{

	/**
	 * 	All the variables and methods are static - to create the only one copy on each PC
	 * 	Each GUI agent call InitializeCommon() and InitializeForAll()
	 * 	Non-gui agent can use it, but they can not use iCurrentLanguage
	 * 	Attention! iCurrentLanguage should be removed in several user agents will work on one PC. 
	 *  
	 * @param args
	 */
	static String[][] sForAll; 
	static String[] sForSelected;
	static int[] iaLanguages;
	static String[] saLanguages;
	static int iCurrentLanguage;
	              
	public static void main( String[] args ) 
	{
		// TODO Auto-generated method stub
	}
	
	static void InitializeForAll()  
	{
		sForAll = new String [83][80];
		sForAll[1][0] = "Name:";
		sForAll[7][0] = "Имя:";
		sForAll[82][0] = "이름:";
		
		sForAll[1][1] = "Password:";
		sForAll[7][1] = "Пароль:";
		sForAll[82][1] = "암호:";
		
		sForAll[1][2] = "Please, enter your username and password";
		sForAll[7][2] = "Please, enter your username and password";
		sForAll[82][2] = "이름과 암호를 넣어주세요";
		
		sForAll[1][3] = "Language:";
		sForAll[7][3] = "Язык:";
		sForAll[82][3] = "언어:";

		sForAll[1][4] = "English";
		sForAll[7][4] = "Английский";
		sForAll[82][4] = "영어";

		sForAll[1][5] = "Korean";
		sForAll[7][5] = "Корейский";
		sForAll[82][5] = "한국어";

		sForAll[1][6] = "Please, enter your login name";
		sForAll[7][6] = "Please, enter your login name";
		sForAll[82][6] = "로그인 이름을 넣어주세요";

		sForAll[1][7] = "Please, enter your password";
		sForAll[7][7] = "Please, enter your password";
		sForAll[82][7] = "암호를 넣어주세요";

		sForAll[1][8] = "Authentication failed. Please, try again.";
		sForAll[7][8] = "Authentication failed. Please, try again.";
		sForAll[82][8] = "인증이 실패했습니다! 다시 시도해주세요.";

		sForAll[1][9] = "Your account is locked. Please contact the system administrator";
		sForAll[7][9] = "Your account is locked. Please contact the system administrator";
		sForAll[82][9] = "당신의 계정은 잠겨있습니다. 시스템 관리자에게 연락해 주세요";

		sForAll[1][10] = "Internal error. Can not start your session. Please, try again later.";
		sForAll[7][10] = "Internal error. Can not start your session. Please, try again later.";
		sForAll[82][10] = "내부 에러. 그 세션을 시작할 수 없습니다. 나중에 다시 시도하세요";

		sForAll[1][11] = "KSNet Server";
		sForAll[7][11] = "Серверная часть системы \"СИЗ\"";
		sForAll[82][11] = "화제";
		
		// LCGUI - buttons (1)
		sForAll[1][12] = "Refresh";
		sForAll[7][12] = "Обновить";
		sForAll[82][12] = "갱신";
		
		sForAll[1][13] = "Test";
		sForAll[7][13] = "Тест";
		sForAll[82][13] = "테스트";

		//	LCGUI - Columns for table:
		sForAll[1][14] = "Description";
		sForAll[7][14] = "Описание";
		sForAll[82][14] = "기술";
		
		sForAll[1][15] = "Type";
		sForAll[7][15] = "Тип";
		sForAll[82][15] = "종류";
		
		sForAll[1][16] = "URL";
		sForAll[7][16] = "URL";
		sForAll[82][16] = "URL (KO)";
		
		sForAll[1][17] = "Status";
		sForAll[7][17] = "Статус";
		sForAll[82][17] = "상태";
	
		sForAll[1][18] = "Hint";
		sForAll[7][18] = "Подсказка";
		sForAll[82][18] = "힌트";
		
		// LCGUI - buttons (2)
		sForAll[1][19] = "Download";
		sForAll[7][19] = "Загрузить";
		sForAll[82][19] = "내려받기";
		
		sForAll[1][20] = "Show";
		sForAll[7][20] = "Показать";
		sForAll[82][20] = "보기";

		// Initial hint
		sForAll[1][21] = "Start";
		sForAll[7][21] = "Начать";
		sForAll[82][21] = "시작할";

		sForAll[1][22] = "This material should be downloaded";
		sForAll[7][22] = "This material should be downloaded";
		sForAll[82][22] = "이 자료는 다운로드 되야 합니다";
		
		// Headers and text for Winmessage
		sForAll[1][23] = "Knowledge Source Network";
		sForAll[7][23] = "Сеть источников знаний";
		sForAll[82][23] = "Knowledge Source Network (KO)";
		
		sForAll[1][24] = "Yes";
		sForAll[7][24] = "Да";
		sForAll[82][24] = "네";
		
		sForAll[1][25] = "No";
		sForAll[7][25] = "Нет";
		sForAll[82][25] = "아니오";

		sForAll[1][26] = "Please, select material";
		sForAll[7][26] = "Please, select material";
		sForAll[82][26] = "학습자료를 선택해주세요";

		sForAll[1][27] = "Learning material";
		sForAll[7][27] = "Учебный материал";
		sForAll[82][27] = "학습 자료";

		sForAll[1][28] = "Internal error. Can not create learning content. Please, try again later.";
		sForAll[7][28] = "Internal error. Can not create learning content. Please, try again later.";
		sForAll[82][28] = "내부 에러. 학습 컨텐츠를 만들 수 없습니다. 나중에 다시 시도하세요.";

		sForAll[1][29] = "Please wait, loading learning content";
		sForAll[7][29] = "Please wait, loading learning content";
		sForAll[82][29] = "기다려주세요. 학습 컨텐츠를 로딩 중입니다";
		
		sForAll[1][30] = "New";
		sForAll[7][30] = "Новый";
		sForAll[82][30] = "새로만들기";

		sForAll[1][31] = "Internal error. This learning content not found. Please, try again later.";
		sForAll[7][31] = "Internal error. This learning content not found. Please, try again later.";
		sForAll[82][31] = "내부 에러. 이 학습 컨텐츠는 찾을 수 없습니다. 나중에 다시 시도하세요.";

		sForAll[1][32] = "Ontology";
		sForAll[7][32] = "Онтология";
		sForAll[82][32] = "Ontology (KO)";

		// Print - for GUI buttons, Close - for viewer
		sForAll[1][33] = "Print";
		sForAll[7][33] = "Печать";
		sForAll[82][33] = "인쇄";
		
		sForAll[1][34] = "Close";
		sForAll[7][34] = "Закрыть";
		sForAll[82][34] = "닫기";

		sForAll[1][35] = "Sorry, this type of document can not be viewed";
		sForAll[7][35] = "Sorry, this type of document can not be viewed";
		sForAll[82][35] = "죄송합니다만, 이런 종류의 문서는 보여질 수 없습니다.";

		sForAll[1][36] = "Viewed";
		sForAll[7][36] = "Просмотрен";
		sForAll[82][36] = "보여짐";
		
		sForAll[1][37] = "Downloaded";
		sForAll[7][37] = "Загружен";
		sForAll[82][37] = "다운로드 완료";

		sForAll[1][38] = "This material can not be downloaded";
		sForAll[7][38] = "This material can not be downloaded";
		sForAll[82][38] = "이 자료는 다운로드 할 수 없습니다.";

		sForAll[1][39] = "You have already downloaded material. Do you want to download it again?";
		sForAll[7][39] = "You have already downloaded material. Do you want to download it again?";
		sForAll[82][39] = "벌써 그 자료를 다운로드 했습니다. 다시 하기를 원하십니까?";

		sForAll[1][40] = "Do you really want to download material?";
		sForAll[7][40] = "Do you really want to download material?";
		sForAll[82][40] = "정말로 그 자료를 다시 다운로드 하길 원하십니까?";

		// Print - for GUI buttons, Close - for viewer
		sForAll[1][41] = "Ask teacher";
		sForAll[7][41] = "Спросить";
		sForAll[82][41] = "요구 teacher (KO)";
		
		sForAll[1][42] = "Forum";
		sForAll[7][42] = "Форум";
		sForAll[82][42] = "재판소 (KO)";

		sForAll[1][43] = "Read mail";
		sForAll[7][43] = "Почта";
		sForAll[82][43] = "음독 mail (KO)";

		sForAll[1][44] = "Exit";
		sForAll[7][44] = "Выход";
		sForAll[82][44] = "출구 (KO)";

		sForAll[1][45] = "Internal error: file not found";
		sForAll[7][45] = "Internal error: file not found";
		sForAll[82][45] = "Internal error: file not found (KO)";

		sForAll[1][46] = "Tests for this topics have not been prepared";
		sForAll[7][46] = "Tests for this topics have not been prepared";
		sForAll[82][46] = "Test for this topics have not been prepared (KO)";
		
		sForAll[1][47] = "Please, select learning topic first";
		sForAll[7][47] = "Please, select learning topic first";
		sForAll[82][47] = "Please, select learning topic first (KO)";

		sForAll[1][48] = "Internal error: can not prepare data for tests. Please contact your system administrator.";
		sForAll[7][48] = "Internal error: can not prepare data for tests. Please contact your system administrator.";
		sForAll[82][48] = "내부에러: can not prepare data for tests. Please contact your system administrator (KO)";

		sForAll[1][49] = "Before pass tests you should study the following topics:";
		sForAll[7][49] = "Before pass tests you should study the following topics:";
		sForAll[82][49] = "Before pass tests you should study the following topics: (KO)";

		sForAll[1][50] = "Before pass tests you should study the following topics in more details:";
		sForAll[7][50] = "Before pass tests you should study the following topics in more details:";
		sForAll[82][50] = "Before pass tests you should study the following topics in more details: (KO)";

		sForAll[1][51] = "To improve your mastery ";
		sForAll[7][51] = "To improve your mastery ";
		sForAll[82][51] = "To improve your mastery (KO) ";
		//	sForAll[1][51] = "To improve your mastery you should study the following topics in more details:";
		//	sForAll[82][51] = "To improve your mastery you should study the following topics in more details: (KO)";

		sForAll[1][52] = "This topic is not available for you yet";
		sForAll[7][52] = "This topic is not available for you yet";
		sForAll[82][52] = "This topic is not available for you yet (KO)";

		sForAll[1][53] = "Next";
		sForAll[7][53] = "След.";
		sForAll[82][53] = "Next (KO)";
		
		sForAll[1][54] = "Prev";
		sForAll[7][54] = "Пред.";
		sForAll[82][54] = "Prev (KO)";
		
		sForAll[1][55] = "Last";
		sForAll[7][55] = "Конец";
		sForAll[82][55] = "Last (KO)";
		
		sForAll[1][56] = "First";
		sForAll[7][56] = "Начало";
		sForAll[82][56] = "First (KO)";
		
		sForAll[1][57] = "You are spending too much time for studying this material";
		sForAll[7][57] = "You are spending too much time for studying this material";
		sForAll[82][57] = "You are spending too much time for studying this material (KO)";
		
		sForAll[1][58] = "Internal error: can not display required material. Please contact your system administrator.";
		sForAll[7][58] = "Internal error: can not display required material. Please contact your system administrator.";
		sForAll[82][58] = "내부에러: can not display required material. Please contact your system administrator (KO)";

		sForAll[1][59] = "Please wait, prepare learning content to display";
		sForAll[7][59] = "Please wait, prepare learning content to display";
		sForAll[82][59] = "Please wait, prepare learning content to display (KO)";

		sForAll[1][60] = "Services";
		sForAll[7][60] = "Сервисы";
		sForAll[82][60] = "Services (KO)";
}
	
	static void InitializeForSelected()  
	{
		
	}

	static void InitializeCommon()  
	{
		//	Attention! The sequence of languages in every drop-down list should correspond to sequence of language codes in this array!  
		iaLanguages = new int [3];
		iaLanguages[0] = 1;
		iaLanguages[1] = 82;
		iaLanguages[2] = 7;
		saLanguages = new String [3];
		saLanguages[0] = "English";
		//saLanguages[1] = "한국어";
        saLanguages[1] = "Korean";
		saLanguages[2] = "Русский";
	}
}

//********************************************
//	static private String SQL_PREPARED_SELECT_STATEMENT_FCONSTR = "SELECT id, term_id, attrout_id, relation_type, relation_id, func_type, func_value, sign FROM func_constr WHERE attrout_id IN ( SELECT id From attr WHERE onto_id = ? )";
//	static private String SQL_PREPARED_SELECT_STATEMENT_FCONSTRATTR = "SELECT funcconstrid, attrid FROM func_attrs WHERE funcconstrid IN ( SELECT id FROM func_constr WHERE attrout_id IN ( SELECT id From attr WHERE onto_id = ? ) )";	//	 	ORDER BY 1

//static private String SQL_PREPARED_SELECT_STATEMENT_WDFunc = "SELECT h.id as hid, 1 AS rt, fc.id as fcid, fc.func_type as fcfunc_type, fc.func_value as fcfunc_value, fa.AttrID as faAttrID, fa.IPID as faIPID from hierarchy h, func_constr fc left join func_attrs fa on (fc.id = fa.funcconstrid) where relation_type = 1 and relation_id = h.id and h.onto_id = ? " +
//		"UNION ALL " +
//		"SELECT h.id as hid, 2 AS rt, fc.id as fcid, fc.func_type as fcfunc_type, fc.func_value as fcfunc_value, fa.AttrID as faAttrID, fa.IPID as faIPID from acon h, func_constr fc left join func_attrs fa on (fc.ID = fa.FuncConstrID) where relation_type = 2 and relation_id = h.id and h.onto_id = ? " +
//		"UNION ALL " +
//		"SELECT h.id as hid, 0 AS rt, fc.id as fcid, fc.func_type as fcfunc_type, fc.func_value as fcfunc_value, fa.AttrID as faAttrID, fa.IPID as faIPID from class h, func_constr fc left join func_attrs fa on (fc.ID = fa.FuncConstrID) where relation_type = 0 and relation_id = h.id and h.onto_id = ?";
//	iiTermID, int iiAttrOutID, int iiRelationType, int iiRelationID, int iiFuncType, int iiFuncValue, int iiSign, int iiIDFromDB

//static private String SQL_PREPARED_SELECT_STATEMENT_VALUES_OF_TEXT_ATTRIBUTES = "SELECT class.id AS classid, attr.id AS attrid, class_attr_id AS classattrid, collectionitem AS attrvalue, stem_collectionitem AS stemattrvalue, domtype_collection.id FROM domtype_collection, class_attr, class, attr WHERE class_attr_id = class_attr.id AND class.id = class_id AND attr.id = attr_id AND class.onto_id = ? AND attr.onto_id = ? AND lang_id = ?";

//	initVars( iiOntoID, "cais.LISA.IIAS.SPB.SU:3306/webdeso", "michael", "12345" );		//	3 is temporary!
//	initVars( iiOntoID, "195.201.73.101:3306/webdeso", "michael", "12345" );		//	3 is temporary!
//initVars( iiOntoID, "cais:3306/webdeso", "michael", "12345" );		//	3 is temporary!
//initVars( iiOntoID, "192.168.0.101:3306/webdeso", "michael", "12345" );

//initVars( iiOntoID, "192.168.0.29:3306/webdeso?useUnicode=true&characterEncoding=latin1", "michael", "12345");
//initVars( iiOntoID, "192.168.0.101:3306/webdeso?useUnicode=true&characterEncoding=latin1", "michael", "12345");

//	stDBDeso = cnDBConnection.createStatement( ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE );
//	pstFConstr = getPreparedStatement( cnDBConnection, SQL_PREPARED_SELECT_STATEMENT_FCONSTR );
//	pstFConstrAttr = getPreparedStatement( cnDBConnection, SQL_PREPARED_SELECT_STATEMENT_FCONSTRATTR );

//	Connection c = DriverManager.getConnection( "jdbc:mysql://cais.LISA.IIAS.SPB.SU:3306/webdeso", "michael", "12345" );
//Connection c = DriverManager.getConnection( "jdbc:mysql://" + isDatabaseName + "?useUnicode=true&characterEncoding=UTF-8", isLogin, isPassword );	//	&autoReconnect=true&useUnbufferedInput=false


//Init cl\assses

/*
if ( bDelIt )
{	
		//	sText = new String ( rsDB.getAsciiStream( "Text" ), "Cpl251" );
	iDelIt ++;
	System.out.println( rsDB.getInt( "ID" ) );
	//	System.out.println( rsDB.getAsciiStream( "Text" ) );

	byte [] buff;	//	 = new byte[4096];
	buff = null;
	//	char [] buff1 = new char[4096];
	java.io.InputStream fin = rsDB.getAsciiStream( "Text" );
		//	java.io.Reader fin1 = rsDB.getCharacterStream( "Text" );
		java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
		java.io.DataOutputStream output = new java.io.DataOutputStream( out );
		for (;;) {
			int size = fin.read( buff );
			//	int size = fin1.read( buff1 );
			if (size == -1) { // at end of stream
					break;
			}


			// Send the newly-filled buffer to some ASCII output stream
			output.write( buff, 0, size );
		}
		System.out.println( buff );
		//	System.out.println( buff1 );
		System.out.println(  new String ( buff, "Cpl251" ) );

		if ( iDelIt > 1 ) bDelIt = false;

};
*/
//	Init attributes

/*
sText = rsDB.getString( "Text" );
if ( sText == null )
{
	sText = "";
};
sDescr = rsDB.getString( "Description" );
if ( sDescr == null )
{
	sDescr = "";
};
sStemText = rsDB.getString( "Stem_Text" );
if ( sText == null )
{
	sStemText = "";
};
sStemDescr = rsDB.getString( "Stem_Description" );
if ( sDescr == null )
{
	sStemDescr = "";
};
*/


//Integer.parseInt( vMessageContent.get( 4 ).toString() );
/*
//	GET FConstrAttr  - BEGIN
//	FuncConstrID, AttrID
pstFConstrAttr.setInt( 1, iOntoID );			//	TEMPORARY
rsDB = pstFConstrAttr.executeQuery();
if ( rsDB.next() )
{
	System.out.println( "Functional constraints details:" );
	do
	{
		System.out.println( "FuncConstrID: " + rsDB.getInt( "FuncConstrID" ) +
				" AttrID: " + rsDB.getInt( "AttrID" )
				);
	} while( rsDB.next() );
}
else
{
	System.out.println( "Functional constraints details not found..." );
}
rsDB = null;
//	GET FConstrAttr - END
*/
/*
static void initFunc()
{
	int iCondID, iCondType, iCondVal, iAttrCondID1[], iAttrCondID2[], iArrLength;	//	to store Condition IDs
	int iRelID, iRelType;
	
	ResultSet rsWDFunc;
	
	WDFunc wdfTemp;
	vWDFunc = null;
	vWDFunc = new Vector();
	//	Vector vArr1, vArr2;
	//	vArr1 = new Vector();
	//	vArr2 = new Vector();
	
	try
	{
		pstWDFunc.setInt( 1, iOntoID );		
		//	pstWDFunc.setInt( 2, iOntoID );
		//	pstWDFunc.setInt( 3, iOntoID );

		rsWDFunc = null;
		rsWDFunc = pstWDFunc.executeQuery();
		
		if ( rsWDFunc.next() )
		{
			iRelID = rsWDFunc.getInt("hid");
			iRelType = rsWDFunc.getInt("rt");
			iCondID = rsWDFunc.getInt("fcid");
			iCondType = rsWDFunc.getInt("fcfunc_type");
			iCondVal = rsWDFunc.getInt("fcfunc_value");
			
			//	vArr1.add(rsWDFunc.getInt("faAttrID"));
			//vArr2.add(rsWDFunc.getInt("faIPID"));
			
			rsWDFunc.next();
			
			do
			{ 	
				if ( iCondID != rsWDFunc.getInt("fcid") ) {
					iAttrCondID1 = null;
					iAttrCondID2 = null;
					iArrLength = vArr1.size();
					iAttrCondID1 = new int[iArrLength];
					iAttrCondID2 = new int[iArrLength];
					for (int i=0; i < vArr1.size(); i++ ){
						iAttrCondID1[i] = Integer.parseInt(vArr1.elementAt(i).toString());
						iAttrCondID2[i] = Integer.parseInt(vArr2.elementAt(i).toString());							
					}
					
					
					wdfTemp = null;
					wdfTemp = new WDFunc(iRelID, iRelType, iCondType==0?true:false, iArrLength, iAttrCondID1, iAttrCondID2 , iCondID);
					vWDFunc.add(wdfTemp);
					
					vArr1 = null;
					vArr2 = null;
					vArr1 = new Vector();
					vArr2 = new Vector();
					
					iRelID = rsWDFunc.getInt("hid");
					iRelType = rsWDFunc.getInt("rt");
					iCondID = rsWDFunc.getInt("fcid");
					iCondType = rsWDFunc.getInt("fcfunc_type");
					iCondVal = rsWDFunc.getInt("fcfunc_value");
				} 
				
				vArr1.add(rsWDFunc.getInt("faAttrID"));
				vArr2.add(rsWDFunc.getInt("faIPID"));
			} while( rsWDFunc.next() );	
		
			iAttrCondID1 = null;
			iAttrCondID2 = null;
			iArrLength = vArr1.size();
			iAttrCondID1 = new int[iArrLength];
			iAttrCondID2 = new int[iArrLength];
			for (int i=0; i < vArr1.size(); i++ ){
				iAttrCondID1[i] = Integer.parseInt(vArr1.elementAt(i).toString());
				iAttrCondID2[i] = Integer.parseInt(vArr2.elementAt(i).toString());
			}
			
			do
			{
				wdfTemp = null;
				//	TermID, AttrOutID, RelationType, RelationID, FuncType, FuncValue, Sign, IDFromDB
				wdfTemp = new WDFunc(
						rsWDFunc.getInt("TermID"),
						rsWDFunc.getInt("AttrOutID"),
						rsWDFunc.getInt("RelationType"),
						rsWDFunc.getInt("RelationID"),
						rsWDFunc.getInt("FuncType"),
						rsWDFunc.getInt("FuncValue"),
						rsWDFunc.getInt("Sign"),
						rsWDFunc.getInt("IDFromDB"),
						0,
						false,
						rsWDFunc.getInt("RelationID")
						);
						
						//	iRelID, iRelType, iCondType==0?true:false,iArrLength, iAttrCondID1, iAttrCondID2 , iCondID);
				vWDFunc.add( wdfTemp );
			} while( rsWDFunc.next() );
		}	//	if next
	}
    catch ( Exception e ) 
    {
    	e.printStackTrace( );
    	return;
    }
}		//	initFunc
*/
/*		//	2007-01-23
try
{
	//	GET COMPATIBLE - BEGIN
	//	Class1_id, Class2_id, Is_compatible
	pstCompatible.setInt( 1, iOntoID );			//	TEMPORARY
	rsDB = pstCompatible.executeQuery();
	if ( rsDB.next() )
	{
		//	System.out.println( "Compatible:" );
		do
		{
			* / *
			System.out.println( " ClassID1: " + rsDB.getInt( "Class1_id" ) +
					" ClassID2: " + rsDB.getInt( "Class2_id" ) +
					" IsCompatible: " + rsDB.getInt( "Is_compatible" )
					);
					* / *
		} while( rsDB.next() );
	}
	else
	{
		//	System.out.println( "Compatible not found..." );
	}
	rsDB = null;
	//	GET COMPATIBLE - END

}
catch ( Exception e ) 
{
	e.printStackTrace( );
	return;
}
*/
/*
if ( bDelIt )
{	
		//	sText = new String ( rsDB.getAsciiStream( "Text" ), "Cpl251" );
	iDelIt ++;
		System.out.println( rsDB.getInt( "ID" ) );
		//	System.out.println( rsDB.getAsciiStream( "Text" ) );

		byte [] buff = new byte[4096];
		char [] buff1 = new char[4096];
		//	java.io.InputStream fin = rsDB.getAsciiStream( "Text" );
		java.io.Reader fin1 = rsDB.getCharacterStream( "Text" );
		java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
		java.io.DataOutputStream output = new java.io.DataOutputStream( out );
		for (;;) {
			//	int size = fin.read( buff );
			int size = fin1.read( buff1 );
			if (size == -1) { // at end of stream
					break;
			}


			// Send the newly-filled buffer to some ASCII output stream
			//	output.write( buff, 0, size );
		}
		//	System.out.println( buff );
		System.out.println( buff1 );
		//System.out.println(  new String ( buff1, "Cpl251" ) );

		if ( iDelIt > 1 ) bDelIt = false;

};
*/

/*
class HttpConnect extends Thread
{
	private Socket sock;
	HttpConnect(Socket s) 
	{
		sock = s;
		setPriority(NORM_PRIORITY - 1);
		start() ;
	}
		
	public void run()
	{
		try
		{
			PrintWriter pw = new PrintWriter(new OutputStreamWriter(
					sock.getOutputStream()), true);
			BufferedReader br = new BufferedReader(new InputStreamReader(
					sock.getInputStream() ) ) ;
			String req = br.readLine();
			System.out.println("Request: " + req);
			StringTokenizer st = new StringTokenizer(req);
			if ((st.countTokens() >= 2) && st.nextToken().equals("POST")){
				if ((req = st.nextToken()).endsWith("/") || req.equals(""))
					req += "index.html";
				try{
					File f = new File(req);
					BufferedReader bfr =
						new BufferedReader(new FileReader(f));
					char[] data = new char[(int)f.length()];
					bfr.read(data);
					pw.println("HTTP/1.1 200 OK\n");
					pw.write(data);
					pw.flush();
				}catch(FileNotFoundException fe){
					pw.println("HTTP/1.1 404 Not Found\n");
				}catch(IOException ioe ){
					System.out.println(ioe);
				}
			}else pw.println("HTTP/l.l 400 Bad Request");
					sock.close();
			}catch(IOException e){
				System.out.println(e);
		}
	}
}
*/


/*
ActionAdapter buttonListener = new ActionAdapter() 
{
    public void actionPerformed( ActionEvent e ) 
    {
       if (e.getActionCommand().equals("Ontology"))
       {
    	   jtaHint.setText( jtaHint.getText() + "\n\r" + "Read ontology from repository, please wait..." );
    	   WDO = new WebDESOOntology( 101 );
    	   jtaHint.setText( jtaHint.getText() + "\n\r" + "Ontology has been read. Waiting for request..." );
			//	System.out.println( "Read ontology" );
       }
       if (e.getActionCommand().equals("Start server"))
       {
    	   try 
    	   {
    		   cnDBConnection = WebDESOOntology.getConnection( "cais:3306/ksnetcontext", "michael", "12345" );
    	   }
    	   catch ( Exception eDBConn ) 
    	   {
    		   WinMessage( "Can not connect to database.", JOptionPane.WARNING_MESSAGE );
    		   //	eDBConn.printStackTrace( );
    		   return;
    	   }
    	   
    	   jtaHint.setText( jtaHint.getText() + "\n\r" + "Starting HTTP server..." );
    	   //	iConnectionStatus = BEGIN_CONNECT;
    	   //	mmObj.run();
       }

       ///////////////////////////////////////////////////////////////////////////////////
       if ( e.getActionCommand().equals("Test") )
       {
//**    	   /*
    	   try
    	   {
				synchronized ( toAppend ) 
				{
					toAppend.append( "Socket keep alive: " + sktMain.getKeepAlive()  );
				}
				SwingUtilities.invokeLater( mmObj );
    	   }
				catch( IOException ioe)
				{
					System.out.println( ioe );
					iConnectionStatus = DISCONNECTED;
				}
//**				* /

    	   // Send data
//**    	   /*
	           out.print(sAnswer); 
	           out.flush();
	           toSend.setLength(0);
	           SwingUtilities.invokeLater( mmObj );
//**	           * /
       	    try 
    	    {
    	          if ( sktMain != null) {
    	        	  sktMain.close();
    	          }
    	    }
    	    catch (IOException ioe ) 
    	    { 
    	    	System.err.println( ioe );
    	    }

       }
       ///////////////////////////////////////////////////////////////////////////////////
       
       if ( e.getActionCommand().equals("Slice") )
       {
    	   buildSlice( 101, new int [] {63218}, new int [] { } );
       }
       
       if ( e.getActionCommand().equals("eDoc") )
       {
    	   callEDoc( );
       }
       

       if (e.getActionCommand().equals("Exit"))
       {
    	   cleanUp();
    	   System.exit( 0 );
       }
    }		//	actionPerformed
};			//	buttonListener

jbOnto.addActionListener( buttonListener );
jbStart.addActionListener( buttonListener );
jbExit.addActionListener( buttonListener );
jbTest.addActionListener( buttonListener );
jbSlice.addActionListener( buttonListener );
jbeDoc.addActionListener( buttonListener );

*/

//************************************************	MainModule
/*

if ( iiSelClasses.length == 0 ) 
{
	oSelClasses = new Object [0];  
	iSelClasses = new int [0];
}
else
{
	oSelClasses =  new Object [ iiSelClasses.length ];
	iSelClasses =  new int [ iiSelClasses.length ];
	for (int i = 0; i< iiSelClasses.length; i++ )
	{
		oSelClasses[i] = new Integer ( iiSelClasses[i] ) ;
		iSelClasses[i] = iiSelClasses[i] ;
	}
}

if ( ( iiSelAttributes.length == 0 ) ) 
{
	oSelAttributes = new Object [0];
	iSelAttributes = new int [0];
}
else
{
	oSelAttributes = new Object [ iiSelAttributes.length ];
	iSelAttributes = new int [ iiSelAttributes.length ];
	for (int i = 0; i< iiSelAttributes.length; i++ )
	{
		oSelAttributes[i] = new Integer ( iiSelAttributes[i] ) ;
		iSelAttributes[i] = iiSelAttributes[i];
	}
}
if ( ! isSelectionCorrect() )
{
	WinMessage( Messages.sForAll[ Messages.iCurrentLanguage ][12], JOptionPane.WARNING_MESSAGE );	// Internal error: Selected elements are not found in the ontology
	return false;
}

for ( int i = 0; i < WDO.vClassAttr.size(); i++ )
{
	clattrTemp = ( ClassAttr )WDO.vClassAttr.elementAt( i );
	iTempAttrID = clattrTemp.getAttrID();
	for ( int j = 0; j < oSelAttributes.length; j++ )
	{
		if ( iSelAttributes[j] == iTempAttrID )
		{
			j = oSelAttributes.length + 1;
			clattrTemp.setIsMarked( true );
		}
	};
};	//	mark out attributes

iTempClassID = -1;
bWasFound = true;
boolean bWasFoundInheritedAttr = false;		//	to check the inherited attributes
boolean bWasFoundNotInheritedAttr = false;	//	to check the inherited attributes

for ( int i = 0; i < WDO.vClassAttr.size(); i++ )
{
	clattrTemp = ( ClassAttr )WDO.vClassAttr.elementAt( i );
	if ( iTempClassID != clattrTemp.getClassID() )		// class has been changed
	{
		changeClass( iTempClassID, bWasFound, bWasFoundInheritedAttr, bWasFoundNotInheritedAttr, i );
		//	re-init vars again
		iTempClassID = clattrTemp.getClassID();
		bWasFound = false;
		bWasFoundInheritedAttr = false;
		bWasFoundNotInheritedAttr = false;
	};
	
	if ( !bWasFound ) bWasFound = !clattrTemp.getIsMarked();
	if ( !bWasFoundInheritedAttr ) bWasFoundInheritedAttr = ( clattrTemp.getClassID() != clattrTemp.getFatherClassID() ) ;
	if ( !bWasFoundNotInheritedAttr ) bWasFoundNotInheritedAttr = ( clattrTemp.getClassID() == clattrTemp.getFatherClassID() ) ;
};
changeClass( iTempClassID, bWasFound, bWasFoundInheritedAttr, bWasFoundNotInheritedAttr, -1 );	//	the last record

//	Put flag IsMarked to classes
for ( int i = 0; i < oSelClasses.length; i++ )
{
	if ( ! WDO.htClasses.containsKey( oSelClasses[i] ) )
	{
		WinMessage( "Class not found: " + Integer.parseInt( oSelClasses[i].toString() ), JOptionPane.WARNING_MESSAGE );
	}
	else
	{
		clTempClass = ( Classes ) WDO.htClasses.get( oSelClasses[i] );
		clTempClass.setIsMarked( true );
	}
};

//	Put flag IsMarked to attributes
for ( int i = 0; i < oSelAttributes.length; i++ )
{
	if ( ! WDO.htAttributes.containsKey( oSelAttributes[i] ) )
	{
		WinMessage( "Attribute not found: " + iSelAttributes[i] , JOptionPane.WARNING_MESSAGE );
	}
	else
	{
		clTempAttr = ( Attributes ) WDO.htAttributes.get( oSelAttributes[i] );
		clTempAttr.setIsMarked( true );
	}
};

markClassWithAttributes();		//	Step 1
buildSlice();					//	Step 2
addLeaves();					// 	Step 3
synchClassesInSliceAndOnto();					//	Synchronize data for further use

int iLoopCount;
iLoopCount = 0;
while ( isClassesLeft() )
{
	iLoopCount++;
	addHier();						// 	Step 4
	synchClassesInSliceAndOnto();					//	Synchronize data for further use
	addAssoc();						// 	Step 5
}

addAttrs();						// 	Step Last
addFunc();						// 	Step Last

slcSliceByRequest.htClasses.put( new Integer( 0 ), new Classes( 0, "Top_of_the_Slice", -1, false, "Instead of thingn", "Thing", "Top level class" ) );	//	add root

*/
/*
private static void changeClass( int iiTempClassID, boolean ibWasFound, boolean ibWasFoundInheritedAttr, boolean ibWasFoundNotInheritedAttr, int iiLoopCount )
{
	if ( iiTempClassID == -1 ) return;
	
	Classes clTemp;
	
	//	if all the marked - change a class in hashtable
	if ( !ibWasFound ) 
	{
		WinMessage( "Class with all marked attributes. ClassID: " + iiTempClassID + " i: " + iiLoopCount, JOptionPane.WARNING_MESSAGE );	//	+ " ClassAttr: " +  clattrTemp
	};
	
	if ( ! WDO.htClasses.containsKey( new Integer( iiTempClassID ) ) )
	{
		WinMessage( "Class with all marked OR/AND inherited attributes. Class not found: " + iiTempClassID, JOptionPane.WARNING_MESSAGE );
	}
	else
	{
		clTemp = ( Classes ) WDO.htClasses.get( new Integer( iiTempClassID ) );
		
		if ( !ibWasFound )clTemp.setIsAllAttrMarked( true );					//	All the attributes are marked
		if ( ibWasFoundInheritedAttr ) clTemp.setHasInheritedAttr( true );		// the class has inherited attribute(s)
		if ( !ibWasFoundNotInheritedAttr ) clTemp.setAllAttrInherited( true );	// all the attributes of the class are inherited
	}
	//	}
	return;
}
	private static void markClassWithAttributes()
	{
		Classes clTemp;
		
		//	Step 1: traverse the leaves
		for (int i = 0; i< WDO.vClasses.size(); i++ )
		{
			clTemp = getClassAtPosition( i, "markClassWithAttributes" );
			
			if ( clTemp != null )
			{
				//	class is a leaf
				if ( clTemp.getIsLeaf() )
				{
					//	class contains attribute(s)
					if ( clTemp.getPosInClassAttr() > 0 )
					{
						//	----------------	get Class ID, position in class-attribute and change isAllAttribute Marked (if necessary)
						//	All the attributes are not inherited and marked
						//	The class is not marked
						if ( clTemp.getIsAllAttrMarked() && !clTemp.getHasInheritedAttr() && !clTemp.getIsMarked() )		// all the attributes are marked
						{
							clTemp.setIsMarked( true );
							WinMessage( "Class was not marked, all the attributes are not inherited and marked: " +  clTemp, JOptionPane.WARNING_MESSAGE );
						}
					}	//	class contains attribute(s)
				}		//	class is a leaf
			}			//  class is not null
		}				//	LOOP
		return;
	}
	
	private static void buildSlice()	// see statechart diagram for details 
	{
		int iFatherID;
		Classes clTemp;
		
		iFatherID = 0;
		clTemp = null;
		
		vQTop = new Vector();
		
		//	ClTemp should be used for IsInsert modification!
		
		//	Search for the thing
		for (int i = 0; i < WDO.vClasses.size(); i++ )
		{
			clTemp = getClassAtPosition( i, "markClassWithAttributes" );
			
			if ( clTemp != null )
			{
				if ( clTemp.getParentID() == iFatherID )	//	THING
				{
					
					getClassChildren( clTemp.getClassID(), i, 1 );
					i = WDO.vClasses.size() + 1;
				}
			
			}			// class is not null
		}				//	LOOP
		while ( vQTop.size() > 0 )
		{
			clTemp = null;
			clTemp = ( Classes )vQTop.elementAt( 0 );
			if ( clTemp.getIsMarked() )		//
			{
				//	FindParent
				findParent( clTemp );
				//	Find IS-A
				findIsA( clTemp );
				// IsInserted
				Object oCurClassID;	//	to find in HashTable
				oCurClassID = new Integer( clTemp.getClassID() );
				clTemp = null;
				clTemp = getClassByKey( oCurClassID, "build Slice, mark class as inserted" );
				if ( clTemp != null ) clTemp.setIsInserted( true );
				clTemp = null;
			}
			else
			{
				getClassChildren( clTemp.getClassID(), 0, 1 );
			}
			
			vQTop.removeElementAt( 0 );
		}
		return;
	}
	
	//	the common method for all the classes
	private static Classes getClassAtPosition( int iiLoopCount, String isMessage ) 
	{
		Object oTemp;
		Classes clTemp;
		
		oTemp = WDO.vClasses.elementAt( iiLoopCount );
		//	return getClassByKey( oTemp, isMessage );
		if ( ! WDO.htClasses.containsKey( oTemp ) )
		{
			WinMessage( "Class not found " + isMessage + ": " + oTemp.toString(), JOptionPane.WARNING_MESSAGE );
			return null;
		}
		else
		{
			return ( Classes ) WDO.htClasses.get( oTemp );
		}
	}
	
	private static Classes getClassByKey( Object ioKeyValue, String isMessage ) 
	{
		Classes clTemp;
		
		if ( ! WDO.htClasses.containsKey( ioKeyValue ) )
		{
			WinMessage( "Class not found " + isMessage + ": " + ioKeyValue.toString(), JOptionPane.WARNING_MESSAGE );
			return null;
		}
		else
		{
			return ( Classes ) WDO.htClasses.get( ioKeyValue );
		}
	}
	
	//	the common method for all the classes
	private static void getClassChildren( int iiParentID, int iiElementToSkip, int iivQTopQToQFrom )
	{
		Classes clTemp;
		clTemp = null;
		
		for (int i = 0; i < WDO.vClasses.size(); i++ )
		{
			if ( i != iiElementToSkip )
			{
				clTemp = getClassAtPosition( i, "get ClassChildren" );
				
				if ( clTemp != null )
				{
					if ( clTemp.getParentID() == iiParentID )
					{
						switch ( iivQTopQToQFrom )
						{
							case 1: 
							{
								vQTop.add( clTemp );
								break;
							}
							case 2: 
							{
								vQTo.add( clTemp );
								break;
							}
							case 3: 
							{
								vQFrom.add( clTemp );
								break;
							}
						}	//	end switch
					}
				}			//	Class is not null
				
			}				//	not skipped element
			
		}				//	LOOP
		return;
	}

	private static void getClassChildrenInSlice( int iiParentID, int iiFlagOfAction )
	{
		Classes clTemp;
		for (int i = 0; i < slcSliceByRequest.vResClasses.size(); i++ )
		{
			clTemp = new Classes( ( Classes ) slcSliceByRequest.vResClasses.elementAt( i ) );
			
			if ( clTemp.getParentID() == iiParentID )
			{
				vQTop.add( clTemp );
				clTemp = null; 
				switch ( iiFlagOfAction )
				{
					case 1:
					{
						( ( Classes ) slcSliceByRequest.vResClasses.elementAt( i ) ).setIsHierProc( true );
						break;
					}
					case 2:
					{
						( ( Classes ) slcSliceByRequest.vResClasses.elementAt( i ) ).setIsAssocProc( true );
						break;
					}
				}
			}
		}				//	LOOP
		
	}

	//	the auxiliary method for buildSlice
	private static int findParent( Classes iclCurrentClass )
	{
		int iParentID, iClassID;
		Object oTemp;
		Classes clTemp, clNewClass;
		
		//	first find the reference in has table to change data
		//	clTemp = iclCurrentClass;
		clTemp = ( Classes ) WDO.htClasses.get( new Integer( iclCurrentClass.getClassID() ) );
		if ( clTemp == null )
		{
			WinMessage( "Class not found: " + "Find InHashTable, ClassID " + iclCurrentClass.getClassID(), JOptionPane.WARNING_MESSAGE );
			return -1;
		}
		
		//	If all the attributes are inherited
		// 	change input parameter - reference to father ID
		//	mark out father
		//	add an IS-A relation with marked to input parameter 	
		
		while ( iclCurrentClass.getAllAttrInherited() )		 
		{
			
			iParentID = iclCurrentClass.getParentID();
			iClassID = iclCurrentClass.getClassID();
			oTemp = new Integer( iParentID );
			
			iclCurrentClass = null;
			//	iclCurrentClass = getClassByKey( oTemp, "Find Parent, ClassID " + iClassID + " ParentID " + iParentID );
			
			if ( ! WDO.htClasses.containsKey(  oTemp ) )
			{
				WinMessage( "Class not found: " + "Find Parent, ClassID " + iClassID + " ParentID " + iParentID, JOptionPane.WARNING_MESSAGE );
				return -1;
			}
			else
			{
				iclCurrentClass = ( Classes ) WDO.htClasses.get( oTemp );
			}
		}
		
		if ( ( clTemp.getClassID() == iclCurrentClass.getClassID()) )
		{
			//	add a relation from thing to the class
			clNewClass = new Classes( clTemp.getClassID(), clTemp.getClassName(), 0, clTemp.getIsLeaf(), clTemp.getClassDescr(), clTemp.getStemClassName(), clTemp.getStemClassDescr() );
			slcSliceByRequest.vResClasses.add( clNewClass );
			slcSliceByRequest.htClasses.put( new Integer( clNewClass.getClassID() ), clNewClass );
			
			iclCurrentClass.setIsInserted( true );
			iclCurrentClass.setIsMarked( true );
		}
		else
		{
			if ( !iclCurrentClass.getIsInserted() )		//	should be inserted and marked
			{
				clNewClass = new Classes( iclCurrentClass.getClassID(), iclCurrentClass.getClassName(), 0, iclCurrentClass.getIsLeaf(), iclCurrentClass.getClassDescr(), iclCurrentClass.getStemClassName(), iclCurrentClass.getStemClassDescr() );
				slcSliceByRequest.vResClasses.add( clNewClass );
				slcSliceByRequest.htClasses.put( new Integer( clNewClass.getClassID() ), clNewClass );

				iclCurrentClass.setIsInserted( true );	// data in hash table is changed
				iclCurrentClass.setIsMarked( true );
			}
			clNewClass = new Classes( clTemp.getClassID(), clTemp.getClassName(), iclCurrentClass.getClassID(), clTemp.getIsLeaf(), clTemp.getClassDescr(), clTemp.getStemClassName(), clTemp.getStemClassDescr() );
			slcSliceByRequest.vResClasses.add( clNewClass );
			slcSliceByRequest.htClasses.put( new Integer( clNewClass.getClassID() ), clNewClass );

			clTemp.setIsMarked( true );
			clTemp.setIsInserted( true );
		}
		return 0;
	};

	private static void findIsA( Classes iclCurrentClass )
	{
		Classes clCurClass, clCurSubClass, clNewClass;
		
		vQFrom = new Vector(); 
		vQTo = new Vector();
		
		vQTo.add( iclCurrentClass );
		
		while ( vQTo.size() > 0 )
		{
			clCurClass = ( Classes ) vQTo.elementAt( 0 );
			vQTo.removeElementAt( 0 );
			vQFrom = null;
			vQFrom = new Vector();
			
			getClassChildren( clCurClass.getClassID(), 0, 3 );
			while ( vQFrom.size() > 0 )
			{
				clCurSubClass = ( Classes ) vQFrom.elementAt( 0 );
				if ( clCurSubClass.getIsMarked() )
				{
					// it is not necessary to change hash table 			FALSE!!!
					clNewClass = new Classes( clCurSubClass.getClassID(), clCurSubClass.getClassName(), clCurClass.getClassID(), clCurSubClass.getIsLeaf(), clCurSubClass.getClassDescr(), clCurSubClass.getStemClassName(), clCurSubClass.getStemClassDescr() );
					slcSliceByRequest.vResClasses.add( clNewClass );
					slcSliceByRequest.htClasses.put( new Integer( clNewClass.getClassID() ), clNewClass );
					
					clCurClass = ( Classes ) WDO.htClasses.get( new Integer( clCurSubClass.getClassID() ) );
					if ( clCurClass == null )
					{
						WinMessage( "Class not found: " + "Find InHashTable1, ClassID " + clCurSubClass.getClassID(), JOptionPane.WARNING_MESSAGE );
						//	return -1;
					}
					else
					{
						clCurClass.setIsInserted( true );
						clCurClass.setIsMarked( true );		//	REDUDANT
					}
					
					vQTo.add( clCurSubClass );
				}
				else
				{
					getClassChildren( clCurSubClass.getClassID(), 0, 3 );
				}
				vQFrom.removeElementAt( 0 );
			}
		}
		return;
	};
	
	private static void addLeaves()		//	Step 3
	{
		int iSaveVResClassesSize, iCurClassID;
		boolean bHasChild;
		Classes clCurClass, clNewClass, clTemp;
		boolean bDebug;
		
		bDebug = true;
		
		iSaveVResClassesSize = slcSliceByRequest.vResClasses.size();
		
		for ( int i = 0; i < iSaveVResClassesSize; i++ )
		{
			bHasChild = false;
			iCurClassID = ( ( Classes ) slcSliceByRequest.vResClasses.elementAt( i ) ).getClassID();
			
			for ( int j = 0; j < iSaveVResClassesSize; j++ )
			{
				if ( iCurClassID ==  ( ( Classes ) slcSliceByRequest.vResClasses.elementAt( j ) ).getParentID() )
				{
					bHasChild = true;
					j = iSaveVResClassesSize + 1;	//	finish the loop
				}
			}
			
			if ( !bHasChild )
			{
				clCurClass = getClassByKey( new Integer ( iCurClassID ), "addLeafs" );
				if ( clCurClass  != null )
				{
					if ( !clCurClass.getIsLeaf() )
					{
						vQFrom = null;
						vQFrom = new Vector();
						getClassChildren( iCurClassID, 0, 3 );
						while ( vQFrom.size() > 0 )
						{
							clCurClass = ( Classes ) vQFrom.elementAt( 0 );
							vQFrom.removeElementAt( 0 );
							if ( clCurClass.getIsLeaf() )
							{
								//	add it
								clNewClass = new Classes( clCurClass.getClassID(), clCurClass.getClassName(), iCurClassID, true, clCurClass.getClassDescr(), clCurClass.getStemClassName(), clCurClass.getStemClassDescr() );
								slcSliceByRequest.vResClasses.add( clNewClass );
								slcSliceByRequest.htClasses.put( new Integer( clNewClass.getClassID() ), clNewClass );
								
								clTemp = ( Classes ) WDO.htClasses.get( new Integer( clCurClass.getClassID() ) );
								if ( clTemp == null )
								{
									WinMessage( "Class not found: " + "Find InHashTable1, ClassID " + clCurClass.getClassID(), JOptionPane.WARNING_MESSAGE );
									//	return -1;
								}
								else
								{
									clTemp.setIsInserted( true );
									clTemp.setIsMarked( true );
								}
							}
							else
							{
								getClassChildren( clCurClass.getClassID(), 0, 3 );
							}
						}
					}	//	Class is not leaf
				}		//	Class has been found in hash table
			}			//	the class does not have any child
		}
		return;
	}

	private static void addHier()		//	Step 4
	{
		//	ATT! QFrom is used in sub-procedure!!!

		int iClass1ID, iLoopCount, iParentID;;
		Classes clTemp;
		WDHier wdhTemp;
		
		clTemp = null;
		
		vQTop = null;
		vQTop = new Vector();
		
		iLoopCount = 0;
		
		//	Search for top-level classes
		getClassChildrenInSlice( 0, 1 );
		
		while ( vQTop.size() > 0 )
		{
			iLoopCount++;
			clTemp = ( Classes ) vQTop.elementAt( 0 ) ;
			vQTop.removeElementAt( 0 );
			iClass1ID = clTemp.getClassID();
			iParentID = clTemp.getParentID();
			
			if ( !clTemp.getIsHierProc() )
			{
				for ( int i = 0; i < WDO.vWDHier.size(); i++ )	//	search for hierarchical relations
				{
					wdhTemp = ( WDHier )WDO.vWDHier.elementAt( i );
					if ( wdhTemp.getClass1ID() == iClass1ID )
					{
						addPartOf( wdhTemp, iParentID );
					}
				}
			}	//	Hierarchical relations are not still precessed
			
			getClassChildrenInSlice( iClass1ID, 1 );
		}
	}
	
	//	private static void addPartOf( int iiClass1ID, int iiClass2ID, boolean ibIsInherited )
	private static void addPartOf( WDHier iwdhPartOf, int iiParentID )
	{
		int iClass1ID, iClass2ID, iTaxonomyParentID, iHierarchyParentID, iClass1IDAux;
		boolean bClass2Found, bIsInherited, bCont, bFoundParentHierarchy; 
		Classes clTemp;
		WDHier wdhAux;
		
		iClass1ID =  iwdhPartOf.getClass1ID();
		iClass2ID =  iwdhPartOf.getClass2ID();
		bClass2Found = slcSliceByRequest.htClasses.containsKey( new Integer( iClass2ID ) );  
		bIsInherited =  iwdhPartOf.getIsInherited();
		iTaxonomyParentID = 0;
		iHierarchyParentID = 0;

		//	Case 1: Is not inherited and HierClass exists
		if ( !bIsInherited && bClass2Found ) 
		{
			slcSliceByRequest.vResHier.add( iwdhPartOf );
			return;
		}

		//	Case 2: Is not inherited and HierClass does not exist
		if ( !bIsInherited && !bClass2Found ) 
		{
			//	follow to the algorithm
			if ( insertClass( iClass2ID ) )
			{
				slcSliceByRequest.vResHier.add( iwdhPartOf );
				return;
			};
			return;
		}

		//	Case 3: Is inherited and HierClass exists
		if ( bIsInherited && bClass2Found ) 
		{
			//	Check parent of the left class.
			boolean bFoundHier;
			bFoundHier = false;
			for ( int i = 0 ; i < slcSliceByRequest.vResHier.size(); i++ )
			{
				WDHier wdhTemp;
				wdhTemp = ( WDHier ) slcSliceByRequest.vResHier.elementAt( i ); 
				if ( ( wdhTemp.getClass1ID() == iiParentID  ) && ( wdhTemp.getClass2ID() == iClass2ID ) )
				{
					bFoundHier = true;
					i = slcSliceByRequest.vResHier.size() + 1;
				}
			}
			if ( bFoundHier )
			{
				// add as-is
				slcSliceByRequest.vResHier.add( iwdhPartOf );
			}
			else
			{
				// add as the first hierarchy
				iwdhPartOf.setIsNotInherited();
				slcSliceByRequest.vResHier.add( iwdhPartOf );
			}
			return;
		}

		//	Case 4: Is inherited and HierClass does not exist
		if ( bIsInherited && !bClass2Found ) 
		{
			//	Search TaxonomyParent
			clTemp = ( Classes )WDO.htClasses.get( new Integer( iClass2ID ) );
			bCont = true;
			while ( bCont )
			{
				if ( clTemp == null )
				{
					//	Say something
					// Impossible situation
					WinMessage( "Wrong Hier1: " + iwdhPartOf, JOptionPane.WARNING_MESSAGE );
					bCont = false;
					return;
				}
				if ( clTemp.getAllAttrInherited() )
				{
					//	TaxonomyParent should be found
					clTemp = ( Classes )WDO.htClasses.get( new Integer( clTemp.getParentID() ) );
				}
				else
				{
					bCont = false;
					iTaxonomyParentID = clTemp.getClassID();
				};
			}	//	End: search for TaxonomyParent

			if ( !clTemp.getIsInserted() )	// TaxonomyParent has to be inserted	
			{
				if ( insertClass( iTaxonomyParentID ) )
				{
					clTemp.setIsInserted( true );	//	it contains the same reference as htClasses => will be changed
				}
				else
				{
					WinMessage( "Error: H: AddTaxPar: " + clTemp, JOptionPane.WARNING_MESSAGE );
					return;
				}
				 	
			};								// TaxonomyParent has to be inserted END

			//	Search HierarchyParent
			clTemp = ( Classes )WDO.htClasses.get( new Integer( iClass1ID ) );	//	
			bCont = true;
			while ( bCont )		//	ATT! ONE LOOP IS NOT NECESSARY
			{
				if ( clTemp == null )
				{
					//	Say something
					// Impossible situation
					WinMessage( "Wrong Hier2: Parent: " + iiParentID + " " + iwdhPartOf, JOptionPane.WARNING_MESSAGE );
					bCont = false;
					return;
				}
				//	Scan WDHier
				bFoundParentHierarchy = false;
				iClass1IDAux = clTemp.getClassID(); 
				for ( int j = 0; j < WDO.vWDHier.size(); j++ )
				{
					wdhAux = ( WDHier ) WDO.vWDHier.elementAt( j );
					if ( ( wdhAux.getClass1ID() == iClass1IDAux ) && ( wdhAux.getClass2ID() == iClass2ID ) )
					{
						j = WDO.vWDHier.size() + 1;
						bFoundParentHierarchy = true;
						if ( !wdhAux.getIsInherited() )
						{
							bCont = false;
							iHierarchyParentID = iClass1IDAux;
						}
						else
						{
							clTemp = ( Classes )WDO.htClasses.get( new Integer( clTemp.getParentID() ) );
						};
					}
				}
				if ( !bFoundParentHierarchy )
				{
					// Impossible situation
					WinMessage( "Wrong Hier3: " + iwdhPartOf, JOptionPane.WARNING_MESSAGE );
					return;
				}
			}	//	End: search for HierarchyParent

			if ( 
					( !clTemp.getIsInserted() )
					&& ( iHierarchyParentID != iTaxonomyParentID )
					)
					// HierarchyParent has to be inserted	
			{
				if ( insertClass( iHierarchyParentID ) )
				{
					clTemp.setIsInserted( true );
				}
				else
				{
					WinMessage( "Error: H: AddHierPar1: " + clTemp, JOptionPane.WARNING_MESSAGE );
					return;
				}
			};

			if ( iTaxonomyParentID != iClass2ID )	// HierarchyClass has to be inserted	
			{
				if ( insertClass( iClass2ID ) )
				{
					
					//	Change IsInserted:
					clTemp = ( Classes )WDO.htClasses.get( new Integer( iClass2ID ) );
					if ( clTemp != null ) clTemp.setIsInserted( true );
					else 
					{
						WinMessage( "Change Inserted error: ID2: " + iClass2ID, JOptionPane.WARNING_MESSAGE );
					}
				}
				else
				{
					WinMessage( "Error: H: AddHierClass: ID2: " + iClass2ID, JOptionPane.WARNING_MESSAGE );
					return;
				}
				 	
			};								// HierarchyClass has to be inserted END

			slcSliceByRequest.vResHier.add( iwdhPartOf );
			//	Check if iTaxonomyParentID != iClass2ID 
		}

		return;
	}
	
	// insert class into slice
	// 1) no superclass - add to Thing, 
	//	make step 3
	//	
	// 2) superclass exists. make IS-A relation. modify relation between descendant and superclasses
	//	--NO! 2.1) no common descendant - , make step 3. TO THINK - is it possible
	//	--IN 2)! 2.2) modify relation between descendant and superclasses
	private static boolean insertClass( int iiClassID )
	{
		Classes clCurClass, clTemp, clNewClass;	//	clTemp - parent and descedant
		int iParentID, iSaveClassID;
		boolean bCont;	//	, bDebug;
		
		bCont = true;
		iParentID = 0;
		
		clCurClass = ( Classes ) WDO.htClasses.get( new Integer ( iiClassID ) );
		if  ( clCurClass == null )
		{
			//	give a message	************************************
			return false;
		}
		
		clTemp = clCurClass;
		while ( bCont )
		{
			iParentID = clTemp.getParentID();
			if ( iParentID == 0 ) bCont = false;
			else
			{
				clTemp = ( Classes ) WDO.htClasses.get( new Integer ( iParentID ) );
				if ( clTemp == null ) 
				{
					//	2DO to say smthng
					bCont = false;
					iParentID = 0;
				}
				else
				{
					if ( clTemp.getIsInserted() ) bCont = false;
				}
			}
		}
		clNewClass = new Classes( clCurClass.getClassID(), clCurClass.getClassName(), iParentID, clCurClass.getIsLeaf(), clCurClass.getClassDescr(), clCurClass.getStemClassName(), clCurClass.getStemClassDescr() );
		slcSliceByRequest.vResClasses.add( clNewClass );
		slcSliceByRequest.htClasses.put( new Integer( clNewClass.getClassID() ), clNewClass );
		
		clCurClass.setIsInserted( true );
		clCurClass.setIsMarked( true );
		
		
		//	find descent or leaves
		vQFrom = null;
		vQFrom = new Vector();
		getClassChildren( iiClassID, 0, 3 );
		
		while ( vQFrom.size() > 0 )
		{
			clTemp = ( Classes ) vQFrom.elementAt( 0 );
			vQFrom.removeElementAt( 0 );
			if ( clTemp.getIsInserted() )
			{
				//	Change parentID. In ideal variant the old father should be Thing (0) or ParentID
				//	find class in vResClasses, change father!
				iSaveClassID = clTemp.getClassID();
				for ( int i = 0; i < slcSliceByRequest.vResClasses.size(); i++ )
				{
					clTemp = ( Classes ) slcSliceByRequest.vResClasses.elementAt( i );
					if ( clTemp.getClassID() == iSaveClassID )	//	find descedendt of father 
					{
						clTemp.setParentID( iiClassID );
						i = slcSliceByRequest.vResClasses.size() + 1;	// finish the loop
					}
				}	//	no check if everything OK. It has to be OK
			}
			else
			{
				if ( clTemp.getIsLeaf() )
				{
					//	add the new class and IS-A relation
					clNewClass = new Classes( clTemp.getClassID(), clTemp.getClassName(), iiClassID, true, clTemp.getClassDescr(), clTemp.getStemClassName(), clTemp.getStemClassDescr() );
					slcSliceByRequest.vResClasses.add( clNewClass );
					slcSliceByRequest.htClasses.put( new Integer( clNewClass.getClassID() ), clNewClass );

					clNewClass = ( Classes ) WDO.htClasses.get( new Integer( clTemp.getClassID() ) );
					if ( clNewClass == null )
					{
						WinMessage( "Class not found: " + "Find InHashTable1, ClassID " + clTemp.getClassID(), JOptionPane.WARNING_MESSAGE );
						//	return -1;
					}
					else
					{
						clNewClass.setIsInserted( true );
						clNewClass.setIsMarked( true );
					}
				}
				else getClassChildren( clTemp.getClassID(), 0, 3 );	//	is not leaf, has not been inserted
			}
		}
		
		
		return true;
	}

	// the function scans vResClasses (slice), finds each of them in htClasses 
	//	and change value of the flag IsInserted  
	private static void synchClassesInSliceAndOnto( )
	{
		
		Classes clTemp;
		Object oClassID;
		for ( int i = 0; i < slcSliceByRequest.vResClasses.size(); i++ )
		{
			oClassID = new Integer( ( ( Classes ) slcSliceByRequest.vResClasses.elementAt( i ) ).getClassID() );
			clTemp = ( Classes ) WDO.htClasses.get( oClassID );
			if ( clTemp == null ) 
			{
				WinMessage( "Synch - class not found " + oClassID, JOptionPane.WARNING_MESSAGE );
			}
			else
			{
				clTemp.setIsInserted( true );
			}
		}
		return;
	}
	
	private static void addAssoc( )
	{

		int iClass1ID, iLoopCount, iParentID;
		Classes clTemp;
		WDAssoc wdaTemp;
		
		clTemp = null;
		
		vQTop = null;
		vQTop = new Vector();
		
		iLoopCount = 0;
		
		//	Search for top-level classes
		getClassChildrenInSlice( 0, 2 );
		
		while ( vQTop.size() > 0 )
		{
			iLoopCount++;
			clTemp = ( Classes ) vQTop.elementAt( 0 ) ;
			vQTop.removeElementAt( 0 );
			iClass1ID = clTemp.getClassID();
			iParentID = clTemp.getParentID();
			
			if ( !clTemp.getIsAssocProc() )
			{
				for ( int i = 0; i < WDO.vWDAssoc.size(); i++ )	//	search for hierarchical relations
				{
					wdaTemp = ( WDAssoc )WDO.vWDAssoc.elementAt( i );
					if ( wdaTemp.getClass1ID() == iClass1ID )
					{
						addAssocOne( wdaTemp, iParentID );
					}
				}
			}		//	Associative constraints are not still processed
			
			getClassChildrenInSlice( iClass1ID, 2 );
		}
		
		return;
	}

	private static void addAssocOne( WDAssoc iwdaRel, int iiParentID )
	{
		int iClass2ID;
		boolean bClass2Found, bIsInherited; 
		iClass2ID = iwdaRel.getClass2ID();
		bClass2Found = slcSliceByRequest.htClasses.containsKey( new Integer( iClass2ID ) );  
		bIsInherited =  iwdaRel.getIsInherited();

		//	Case 1
		if ( !bIsInherited && bClass2Found ) 
		{
			slcSliceByRequest.vResAssoc.add( iwdaRel );
			return;
		}

		//	Case 2
		if ( !bIsInherited && !bClass2Found ) 
		{
			//	The same algorith as for hierarchy relations
			if ( insertClass( iClass2ID ) )
			{
				slcSliceByRequest.vResAssoc.add( iwdaRel );
			};
			return;
		}
		
		//	Case 3
		if ( bIsInherited && bClass2Found ) 
		{
			//	Check parent of the left class.
			//	The same code as in HIER!
			boolean bFoundAssoc;
			bFoundAssoc = false;
			for ( int i = 0 ; i < slcSliceByRequest.vResAssoc.size(); i++ )
			{
				WDAssoc wdaTemp;
				wdaTemp = ( WDAssoc ) slcSliceByRequest.vResAssoc.elementAt( i ); 
				if ( ( wdaTemp.getClass1ID() == iiParentID  ) && ( wdaTemp.getClass2ID() == iClass2ID ) )
				{
					bFoundAssoc = true;
					i = slcSliceByRequest.vResAssoc.size() + 1;
				}
			}
			if ( bFoundAssoc )
			{
				// add as-is
				slcSliceByRequest.vResAssoc.add( iwdaRel );
			}
			else
			{
				// add like first assoc relation
				iwdaRel.setIsNotInherited();
				slcSliceByRequest.vResAssoc.add( iwdaRel );
			}
			return;
		}

		if ( bIsInherited && !bClass2Found ) 
		{
			//	2do
			insertAssocInher( iwdaRel.getClass1ID(), iClass2ID );
		}
		return;
	}

	private static void insertAssocInher( int iiClass1ID, int iiClass2ID )
	{
		Classes clCurClass, clTemp, clNewClass;	//	clTemp - parent and descedant
		int iParentID;
		boolean bCont, bFound;
		
		bCont = true;
		bFound = false;
		iParentID = 0;
		
		clCurClass = ( Classes ) WDO.htClasses.get( new Integer ( iiClass2ID ) );
		if  ( clCurClass == null )
		{
			//	give a message	************************************
			//	return false;
			return;
		}
		
		// search for parent - start
		//	bFound = false;
		clTemp = clCurClass;
		while ( bCont )
		{
			iParentID = clTemp.getParentID();
			clTemp = ( Classes ) WDO.htClasses.get( new Integer ( iParentID ) );
			if ( ( iParentID == 0 ) || ( clTemp == null ) ) bCont = false;
			else
			{
				if ( clTemp.getIsInserted() ) 
				{
					bCont = false;
					bFound = true;
				}
			}
		}
		//	search for parent - end

		if ( !bFound )	//	iParentID == 0 ) //	search for descender
		{
			vQFrom = null;
			vQFrom = new Vector();
			getClassChildren( iiClass2ID, 0, 3 );
			bCont = true;
			while ( ( vQFrom.size() > 0 )&& bCont )
			{
				clTemp = ( Classes ) vQFrom.elementAt( 0 );
				vQFrom.removeElementAt( 0 );
				iParentID = clTemp.getClassID();
				if ( clTemp.getIsInserted() ) 
				{
					bCont = false;
					bFound = true;
				}
				else getClassChildren( clTemp.getClassID(), 0, 3 );
			}
		}

		if ( bFound )	//	( iParentID != 0 ) //	parent has been found 
		{
			WDAssoc wdaTemp;
			wdaTemp = new WDAssoc( iiClass1ID, iParentID, false, iiClass1ID, -1 );	//	No ID!
			slcSliceByRequest.vResAssoc.add( wdaTemp );
			// DELETE REFERENCES TO THE ID TO SPEED-UP THE PROCESS. At the moment - no sence
			return;
		}
		
		if ( insertClass( iiClass2ID ) )
		{
			WDAssoc wdaTemp;
			wdaTemp = new WDAssoc( iiClass1ID, iiClass2ID, false, iiClass1ID, -1 );	//	No ID!
			slcSliceByRequest.vResAssoc.add( wdaTemp );
			return;
		};
		
	}	//	insertAssocInher

	private static void addAttrs()		//	Step Last
	{
		//	ATT! QFrom is used in sub-procedure!!!

		int iClassID, iLoopCount, iParentID, iAttrID;
		Classes clTemp;
		Attributes attrTemp;
		ClassAttr caTemp, caTempSlice;
		boolean bFound;
		
		clTemp = null;
		
		vQTop = null;
		vQTop = new Vector();
		
		iLoopCount = 0;
		
		//	Search for top-level classes
		getClassChildrenInSlice( 0, 3 );
		while ( vQTop.size() > 0 )
		{
			iLoopCount++;
			clTemp = ( Classes ) vQTop.elementAt( 0 ) ;
			vQTop.removeElementAt( 0 );
			iClassID = clTemp.getClassID();
			iParentID = clTemp.getParentID();
			for ( int i = 0; i < WDO.vClassAttr.size(); i++ )	//	search for attributes
			{
				caTemp = ( ClassAttr )WDO.vClassAttr.elementAt( i );
				if ( caTemp.getClassID() == iClassID )
				{
					//	Check if it is inherited
					//	Not inherited - add relation, add attribute
					if ( !caTemp.getIsInherited() ) slcSliceByRequest.vResClassAttr.add( caTemp );
					else
					{
						//	Find attribute in parent's class
						iAttrID = caTemp.getAttrID();
						bFound = false;
						for ( int j = 0; j < slcSliceByRequest.vResClassAttr.size(); j++ )
						{
							caTempSlice = ( ClassAttr )slcSliceByRequest.vResClassAttr.elementAt( j );
							if ( ( caTempSlice.getClassID() == iParentID ) && ( caTempSlice.getAttrID() == iAttrID ) )
							{
								bFound = true;
								j = slcSliceByRequest.vResClassAttr.size() + 1;
							}
						}
						if ( bFound )
						{
							slcSliceByRequest.vResClassAttr.add( caTemp );
						}
						else
						{
							slcSliceByRequest.vResClassAttr.add( new ClassAttr( iClassID, iAttrID, false, iClassID) );
						}
					}	//	Inherited
				}		//	Class is equal
			}			//	Loop by pairs of classes and attributes
			getClassChildrenInSlice( iClassID, 3 );
		}	//	endwhile
		
		for ( int j = 0; j < slcSliceByRequest.vResClassAttr.size(); j++ )
		{
			caTempSlice = ( ClassAttr )slcSliceByRequest.vResClassAttr.elementAt( j );
			if ( !caTempSlice.getIsInherited() )
			{
				iAttrID = caTempSlice.getAttrID();
				attrTemp = ( Attributes ) WDO.htAttributes.get( new Integer( iAttrID ) );
				if ( attrTemp != null )
				{
					slcSliceByRequest.vResAttr.add( attrTemp );
					//	HASH TABLE
				}
			}
		}
		
	}
	private static void addFunc()		//	Step Last
	{

	}					
	
	private static boolean isClassesLeft()		//	Step Last
	{
		for (int i = 0; i< slcSliceByRequest.vResClasses.size(); i++ )
		{
			if ( 
					( !( ( Classes )slcSliceByRequest.vResClasses.elementAt( i ) ).getIsAssocProc() ) 
					|| ( !( ( Classes )slcSliceByRequest.vResClasses.elementAt( i ) ).getIsAssocProc() )
				) 
			{
				//	if ( i != 197 )
				return true;
			};
		}
		return false;
	}
	//	******************************************************	Slice part - END

*/

//	***********************	SLICING
//	System.out.println( "Number of compatible relations to be taken into account: " + iCompatibleClassesID.length );
//	for ( int i = 0; i < iCompatibleClassesID.length; i++ ) System.out.println( "ClassID: " + iCompatibleClassesID[ i ] );
//	System.out.println( "Number of forbidden classes before traverse: " + htForbiddenClasses.size() );

//for ( int i = 0; i < htForbiddenClasses.size(); i++ ) System.out.println( "ClassID: " + htForbiddenClasses.get( new Integer( i ) ));

//	Mark out attributes in pairs Class + Attribute
//	System.out.println( "\nStart attributes marking in pairs..." );

/*
private static void addHier1()		//	Step 4		// DEL IT!!!!
{
	System.out.println( "Step 4 is starting..." );
	int iClass1ID, iClass2ID;
	WDHier wdhTemp;
	boolean bClass1Found, bClass2Found, bIsInherited; 
	
	for( int i = 0; i < WDO.vWDHier.size(); i++ )
	{
		wdhTemp = ( WDHier )WDO.vWDHier.elementAt( i );
		iClass1ID =  wdhTemp.getClass1ID();
		iClass2ID =  wdhTemp.getClass2ID();
		bClass1Found =  htClasses.containsKey( new Integer( iClass1ID ) );
		bClass2Found = htClasses.containsKey( new Integer( iClass2ID ) );  
		bIsInherited =  wdhTemp.getIsInherited();
		
		if ( !bIsInherited && bClass1Found && bClass2Found ) 
		{
			vResHier.add( wdhTemp );
			System.out.println( WDO.vWDHier.elementAt( i ) );
		};
		if ( !bIsInherited && bClass1Found && !bClass2Found ) 
		{
			//	addPartOf( iClass1ID, iClass2ID );
		};
		if ( !bIsInherited && !bClass1Found && bClass2Found ) 
		{
			//	addPartOf();
		};
	}
	System.out.println( "Step 4 has been finished" );
}
*/
//	Print pairs of classes and attributes


// ************************************************************************ - BEGIN DEBUG

/*		Smtng OLD					//	2006-06-28	PMNew
//	Save attributes if necessary
if ( WDO.htAttributes.size() > 0 )
{
	oTemp = null;
	oTemp =  new Object [ WDO.htAttributes.size() ];
	oTemp =  WDO.htAttributes.values().toArray();
	for ( int i = 0; i < oTemp.length; i++ )
	{
		//	System.out.println( oTemp[ i ].toString() );
	};
};
*/


/*
//	Debug - print info about classes which are marked or have all marked attributes
//	Save classes if necessary
Classes clClassArr [];
if ( WDO.htClasses.size() > 0 )
{
	oTemp = null;
	oTemp =  new Object [ WDO.htClasses.size() ];
	oTemp =  WDO.htClasses.values().toArray();
	//	clClassArr = null;
	//	clClassArr =  new Classes [ WDO.htClasses.size() ];
	//	clClassArr =  ( Classes [] ) WDO.htClasses.values().toArray();

	for ( int i = 0; i < oTemp.length; i++ )
	{
		if ( ( ( Classes )oTemp[ i ] ).getIsMarked() || ( ( Classes )oTemp[ i ] ).getIsAllAttrMarked() )
		{
			System.out.println( oTemp[ i ].toString() );
		}
	};
};
*/

//************************************************************************ - END DEBUG

/*
private static void addFuncOld()		//	Step Last
{
	WDHier wdhTemp;
	Vector vQHierID;
	int j, k;
	WDFunc wdfTemp;
	
	vQHierID = null;
	vQHierID = new Vector();
	
	System.out.println( "Start getting functional constraints..."  );
	
	j = 0;			
	for ( int i = 0; i < vResHier.size(); i++) {
		wdhTemp = null;
		wdhTemp = (WDHier)vResHier.elementAt(i);
			
		if (vQHierID.contains(wdhTemp.getIDFromDB()) == false)
		{				
			if (j < WDO.vWDFunc.size()) {
				do {	
					wdfTemp = null;
					wdfTemp = (WDFunc)WDO.vWDFunc.elementAt(i);
					if ( 2 == 1 ) // (wdfTemp.getConstType() == 1) 
						//vQHierID.add(wdfTemp.getConstID());
					//else 
					//	vQHierID.add(0);
					
					j++;
				} while (j < WDO.vWDFunc.size() && vQHierID.contains(wdhTemp.getIDFromDB()));
			}						
		};
			
		// if it is func costrains on restriction 
		if (vQHierID.contains(wdhTemp.getIDFromDB()) == true)
		{	
			wdfTemp = null;
			wdfTemp = (WDFunc)WDO.vWDFunc.elementAt(vQHierID.indexOf(wdhTemp.getIDFromDB()));
				
			//	if it is classes from TMO and DO
			if ( 2 == 1 ) //	(wdfTemp.isMethod()) 
			{
				*	This part will be used if not all atributes will added to slice
				*						k = 0;
				*						
				*						while (k < wdfTemp.getDOAttrs().length  
				*								&& (wdfTemp.getDOAttrs()[k] != 0 && vResAttr.contains(( Attributes ) WDO.htAttributes.get(wdfTemp.getDOAttrs()[k])))
				*								&& (wdfTemp.getTMOAttrs()[k] != 0 && vResAttr.contains(( Attributes ) WDO.htAttributes.get(wdfTemp.getTMOAttrs()[k])))) 
				*							k++;
				*
				*						// attributes are in pairs
				*						if (k < wdfTemp.getDOAttrs().length)
				*						{
				*
										// B							
				vResFunc.add(wdfTemp);
				/*						} 
				*						// attributes are not in pairs
				*						else 
				*						{
				/*	This part will be used if not all atributes will added to slice
				*							// C
				*							vResFunc.add(wdfTemp);
											
										}
				*				
			} 
			// if it is classes from DO
			else 
			{
				*	This part will be used if not all atributes will added to slice
				 * 					// attributes are not in pairs						
				 * 					k = 0;
				*							
				*						while (k < wdfTemp.getDOAttrs().length) {
				*							if (wdfTemp.getDOAttrs()[k] == 0 || wdfTemp.getTMOAttrs()[k] == 0){
				*								System.out.println( "Mistake in base: pair to atribute does not given");
				*								return;
				*							}
				*								
				*
				*							if (vResAttr.contains(( Attributes ) WDO.htAttributes.get(wdfTemp.getDOAttrs()[k]))){
				*								
				*							}								 
				*							if (vResAttr.contains(( Attributes ) WDO.htAttributes.get(wdfTemp.getTMOAttrs()[k])))	
				*							{
				*								j = 0;
				*								while (j < WDO.vClassAttr.size() && ((ClassAttr)WDO.vClassAttr.get(j)).getAttrID() != (( Attributes )WDO.htAttributes.get(wdfTemp.getTMOAttrs()[k])).getAttrID() && !((ClassAttr)WDO.vClassAttr.get(j)).getIsInherited())
				*									j++;
				*								if (j < WDO.vClassAttr.size()){
				*									
				*									vResClasses.add((Classes)WDO.htClasses.get(((ClassAttr)WDO.vClassAttr.get(j)).getClassID()));
				*								}
				*							}
				*							k++;
				*
			}												
		}
	}		//	for
	System.out.println( "Finish getting functional constraints"  );
}			
*/

/* 2007-01-17.
//	Search HierarchyParent
clTemp = ( Classes )WDO.htClasses.get( new Integer( iClass1ID ) );	//	
bCont = true;
while ( bCont )		//	ATT! ONE LOOP IS NOT NECESSARY
{
	if ( clTemp == null )
	{
		//	Say something
		// Impossible situation
		System.out.println( "Wrong Hier2: Parent: " + iiParentID + " " + iwdhPartOf );
		bCont = false;
		return;
	}
	//	Scan WDHier
	bFoundParentHierarchy = false;
	iClass1IDAux = clTemp.getClassID(); 
	for ( int j = 0; j < WDO.vWDHier.size(); j++ )
	{
		wdhAux = ( WDHier ) WDO.vWDHier.elementAt( j );
		if ( ( wdhAux.getClass1ID() == iClass1IDAux ) && ( wdhAux.getClass2ID() == iClass2ID ) )
		{
			j = WDO.vWDHier.size() + 1;
			bFoundParentHierarchy = true;
			if ( !wdhAux.getIsInherited() )
			{
				bCont = false;
				iHierarchyParentID = iClass1IDAux;
			}
			else
			{
				clTemp = ( Classes )WDO.htClasses.get( new Integer( clTemp.getParentID() ) );
			};
		}
	}
	if ( !bFoundParentHierarchy )
	{
		// Impossible situation
		System.out.println( "Wrong Hier3: " + iwdhPartOf );
		return;
	}
}	//	End: search for HierarchyParent


if ( 
		( !clTemp.getIsInserted() )
		&& ( iHierarchyParentID != iTaxonomyParentID )
		)
		// HierarchyParent has to be inserted	
{
	if ( insertClass( iHierarchyParentID ) )
	{
		if ( bDebugHier ) System.out.println( "H: AddHierPar: " + clTemp );		//	2006-06-28	PMNew
		clTemp.setIsInserted( true );
	}
	else
	{
		System.out.println( "Error: H: AddHierPar1: " + clTemp );
		return;
	}
};
//else	//	Something Wrong!
//{
//	System.out.println( "Error: H: AddHierPar2: " + clTemp );
//	return;
//};								// HierarchyParent has to be inserted END

*/
